﻿namespace mVids
{
    using MediaPortal.Configuration;
    using MediaPortal.Profile;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class viewParseResults : UserControl
    {
        private ColumnHeader columnHeader1;
        private ColumnHeader columnHeader2;
        private ColumnHeader columnHeader3;
        private ColumnHeader columnHeader4;
        private ColumnHeader columnHeader5;
        private IContainer components;
        private GroupBox groupBox1;
        private Label label1;
        private Label label2;
        private Label label3;
        private ListView listView1;
        public TextBox maskBox;
        public string[] masks;
        public ComboBox pathBox;

        public viewParseResults()
        {
            bool flag;
            this.components = null;
            this.InitializeComponent();
            Settings settings = new Settings(Config.GetFolder(Config.Dir.Config) + "/MediaPortal.xml", true);
            string[] strArray = settings.GetValue("mvid", "basepath").Split("|".ToCharArray());
            string str = settings.GetValue("mvid", "masks");
            this.masks = settings.GetValue("mvid", "masks").Split("|".ToCharArray());
            settings.Dispose();
            if (str == "")
            {
                flag = true;
                this.masks = new string[strArray.Length];
            }
            else
            {
                flag = false;
            }
            for (int i = 0; i < strArray.Length; i++)
            {
                if (Directory.Exists(strArray[i]))
                {
                    string[] strArray2 = new string[2];
                    strArray2[0] = strArray[i];
                    if (flag)
                    {
                        this.masks[i] = "IGNORE";
                    }
                    this.pathBox.Items.Add(strArray[i]);
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.listView1 = new ListView();
            this.columnHeader1 = new ColumnHeader();
            this.columnHeader2 = new ColumnHeader();
            this.columnHeader5 = new ColumnHeader();
            this.columnHeader3 = new ColumnHeader();
            this.columnHeader4 = new ColumnHeader();
            this.groupBox1 = new GroupBox();
            this.maskBox = new TextBox();
            this.label3 = new Label();
            this.label2 = new Label();
            this.pathBox = new ComboBox();
            this.label1 = new Label();
            this.groupBox1.SuspendLayout();
            base.SuspendLayout();
            this.listView1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.listView1.Columns.AddRange(new ColumnHeader[] { this.columnHeader1, this.columnHeader2, this.columnHeader5, this.columnHeader3, this.columnHeader4 });
            this.listView1.GridLines = true;
            this.listView1.LabelEdit = true;
            this.listView1.Location = new Point(3, 3);
            this.listView1.Name = "listView1";
            this.listView1.Size = new Size(0x224, 0xf3);
            this.listView1.TabIndex = 1;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.listView1.View = View.Details;
            this.columnHeader1.Text = "Filename";
            this.columnHeader1.Width = 0x70;
            this.columnHeader2.Text = "Parsed Artist";
            this.columnHeader2.Width = 0x74;
            this.columnHeader5.Text = "Parsed Title";
            this.columnHeader5.Width = 0x69;
            this.columnHeader3.Text = "Parsed Tags";
            this.columnHeader3.Width = 70;
            this.columnHeader4.Text = "Parsed last.fm name";
            this.columnHeader4.Width = 0x7f;
            this.groupBox1.Controls.Add(this.maskBox);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.pathBox);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Dock = DockStyle.Bottom;
            this.groupBox1.Location = new Point(0, 0xf9);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x227, 0x53);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Parsing Rule";
            this.maskBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.maskBox.Enabled = false;
            this.maskBox.Location = new Point(0x29, 0x31);
            this.maskBox.Name = "maskBox";
            this.maskBox.Size = new Size(320, 20);
            this.maskBox.TabIndex = 0;
            this.label3.AutoSize = true;
            this.label3.Location = new Point(7, 0x35);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x21, 13);
            this.label3.TabIndex = 6;
            this.label3.Text = "Mask";
            this.label2.AutoSize = true;
            this.label2.Location = new Point(10, 0x19);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x1d, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Path";
            this.pathBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.pathBox.FormattingEnabled = true;
            this.pathBox.Location = new Point(0x29, 0x16);
            this.pathBox.Name = "pathBox";
            this.pathBox.Size = new Size(320, 0x15);
            this.pathBox.TabIndex = 4;
            this.label1.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x16f, 0x11);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x95, 0x34);
            this.label1.TabIndex = 1;
            this.label1.Text = "%tags% - Tag Value\r\n%artist% - Name of Artist\r\n%last.fm% - last.fm Artist Name\r\n%ignore% - Ignore Value";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.groupBox1);
            base.Controls.Add(this.listView1);
            base.Name = "viewParseResults";
            base.Size = new Size(0x227, 0x14c);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            base.ResumeLayout(false);
        }

        public void loadItems(List<mVids.musicVideo> vids)
        {
            this.listView1.Items.Clear();
            foreach (mVids.musicVideo video in vids)
            {
                ListViewItem item = new ListViewItem(new string[] { video.Path, video.artist, video.Label, video.aI.tags, video.aI.lfmName });
                this.listView1.Items.Add(item);
            }
        }
    }
}

